package structure.composite;

public class Client {
    public static void main(String[] args) {
        //针对抽象构件编程
        Component file1, file2, file3, file4, file5;
        Container folder1, folder2, folder3, folder4;

        folder1 = new Container("根文件夹");
        folder2 = new Container("文件夹2");
        folder3 = new Container("文件夹3");
        folder4 = new Container("文件夹4");

        file1 = new LeafOne("小龙女.jpg");
        file2 = new LeafOne("张无忌.gif");
        file3 = new LeafTwo("九阴真经.txt");
        file4 = new LeafTwo("葵花宝典.doc");
        file5 = new LeafTwo("笑傲江湖.rmvb");


        folder2.add(file1);
        folder2.add(file2);
        folder3.add(file3);
        folder3.add(file4);
        folder4.add(file5);
        // 根文件夹add
        folder1.add(folder2);
        folder1.add(folder3);
        folder1.add(folder4);

        //开始递归执行业务方法
        folder1.operation();
    }
}
